package com.atguigu.lease.web.admin.service.impl;

import com.atguigu.lease.model.enums.BaseStatus;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.UserInfo;
import com.atguigu.lease.web.admin.service.UserInfoService;
import com.atguigu.lease.web.admin.mapper.UserInfoMapper;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author liubo
* @description 针对表【user_info(用户信息表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
    implements UserInfoService{
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public void updateStatusById(Long id, BaseStatus status) {


//        LambdaQueryWrapper<UserInfo> statusWrapper = new LambdaQueryWrapper<>();
//        statusWrapper.eq(UserInfo::getId,id);
////        statusWrapper.set(UserInfo::getStatus,status);
//        statusWrapper.in(UserInfo::getStatus,BaseStatus.ENABLE,BaseStatus.DISABLE);
////        statusWrapper.eq(UserInfo::getStatus, BaseStatus.ENABLE);
////        statusWrapper.eq(UserInfo::getStatus, BaseStatus.DISABLE);
        LambdaUpdateWrapper<UserInfo> objectLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        objectLambdaUpdateWrapper
                .eq(UserInfo::getId,id)
                .in(UserInfo::getStatus,BaseStatus.ENABLE,BaseStatus.DISABLE)
                .set(UserInfo::getStatus,status);
        userInfoMapper.update(null,objectLambdaUpdateWrapper);
//        userInfoMapper.update(statusWrapper);
//        userInfoMapper.updateStatusById(id,status);
    }
}




